package model;

import com.fasterxml.jackson.annotation.JsonInclude;
import enums.BaseRespCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;

/**
 * @author: Anc
 * @date: 2022/7/01
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class Response<T> extends BaseObject implements Serializable {

    private static final long serialVersionUID = 1354372412552747154L;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private int code;
    /**
     * 提示信息
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String msg;
    /**
     * 业务响应数据
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private T result;
    /**
     * 签名串
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String sign;

    public Response() {
        this(null, BaseRespCodeEnum.SUC.getCode(), BaseRespCodeEnum.SUC.getMsg());
    }


    public Response(String msg, T result) {
        this.msg = msg;
        this.result = result;
    }


    public Response(T result) {
        this(result, BaseRespCodeEnum.SUC.getCode(), BaseRespCodeEnum.SUC.getMsg());
    }

    public Response(T result, int code, String msg) {
        this.result = result;
        this.code = code;
        this.msg = msg;
    }

    public Response(int code, String msg, T result) {
        this.result = result;
        this.code = code;
        this.msg = msg;
    }

    public Response(int code, String msg) {
        this(null, code, msg);
    }
}
